#pragma once

#include <string>
using namespace std;

#include "topdbs_common.hpp"

namespace topdbs
{
	typedef
	enum eDBSDataType
	{
		DBS_dtUnknown, //!< data type is unknown
		DBS_dtBool, //!< data type is C bool
		DBS_dtShort, //!< data type is C short
		DBS_dtUShort, //!< data type is C unsigned short
		DBS_dtInt32, //!< data type is C  int
		DBS_dtUInt32, //!< data type is C  unsigned int
		DBS_dtLong, //!< data type is C long
		DBS_dtULong, //!< data type is C unsigned long
		DBS_dtInt64, //!< data type is 8-bit integer
		DBS_dtUInt64, //!< data type is 8-bit unsigned integer
		DBS_dtFloat, //!< data type is C float
		DBS_dtDouble, //!< data type is C double
		DBS_dtDateTime, //!< data type is DateTime
		DBS_dtInterval, //!< data type is Interval (MySQL specific - for MySQL TIME data type)
		DBS_dtString, //!< data type is character string (String)
		DBS_dtBLob, //!< data type is BLob data (String)
		DBS_dtCLob, //!< data type is CLob data (String)
		DBS_dtCursor, //!< data type is Oracle REF CURSOR (SACommand - for Oracle only)
		DBS_dtText,  //! data type is TEXT data (String )
		DBS_DataType_Reserved = (int)(((unsigned int)(-1)) / 2)
	} DBSDataType_t;

	class TOPDBS_API DBSValue
	{
	protected:
		DBSDataType_t m_dateType;
		string m_string;
		union uScalars
		{
			bool m_Bool;
			short m_Short;
			unsigned short m_uShort;
			int m_Int32;
			int m_uInt32;
			long m_Long;
			unsigned long m_uLong;
			int64_t m_Int64;
			uint64_t m_uInt64;
			float  m_Float;
			double m_Double;
		} m_InternalScalar;

	public:
		DBSValue();
		DBSDataType_t DataType() const;
		string toString() const;

		bool asBool() const;
		short asShort() const;
		unsigned short asUShort() const;
		short asInt() const;
		unsigned short asUInt() const;	
		long asLong() const;
		unsigned long asULong() const;
		int64_t asInt64() const;
		uint64_t asUInt64() const;
		float asFloat() const;
		double asDouble() const;
		string asString() const;
		string asText() const;
		string asBlob() const;
		string asClob() const;

		DBSValue& setAsBool(bool ) ;
		DBSValue& setAsShort(short) ;
		DBSValue& setAsUShort(unsigned short);
		DBSValue& setAsInt(int) ;
		DBSValue& setAsUInt(unsigned int);	
		DBSValue& setAsLong(long) ;
		DBSValue& setAsULong(unsigned long);
		DBSValue& setAsInt64(int64_t) ;
		DBSValue& setAsUInt64(uint64_t) ;
		DBSValue& setAsFloat(float) ;
		DBSValue& setAsDouble(double) ;
		DBSValue& setAsString(const string& ) ;	
		DBSValue& setAsText(const string& ) ;	
		DBSValue& setAsBlob(const string& ) ;	
		DBSValue& setAsBlob(const unsigned char*,size_t ) ;
		DBSValue& setAsClob(const string& ) ;
	};
}
